﻿<%--
 *  File:    ProdCategoryTree.jsp
 *  @Author: Langerwang 
 *  Date:    2001/01/14
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.ProdCategoryTree");  
  String strModuleName = "PCM";  
  String privilegeCode = "10203,L203";
%>

<%
  HashMap userInfo = (HashMap)session.getAttribute("userinfo");  
  Integer nCurOrgId = (Integer)userInfo.get("orgid");
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="prodcategorytree"/>
<%
  Vector categories = (Vector)pageContext.getAttribute("categorytree");
      
  if(categories == null)
    categories = new Vector();
  cat.debug("The categories is :" + categories.size() + categories);
  OvalTree initTree = new OvalTree(categories,"categoryid","parentcategoryid","grade");
  initTree.setRecursiveLimit(2000);
  Vector categoryTree = (Vector)initTree.getTreeVector(new Integer(-1000),1);  
  cat.debug("The tree's size is :" + categoryTree.size());
  cat.debug("The tree is :" + categoryTree);
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<SCRIPT language=JavaScript1.2 src="../../css/menu.js"></SCRIPT>
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<link rel="stylesheet" href="../../css/cn/widget.css" type="text/css">
<script language="JavaScript" src="../../js/opal2/mootools.js"></script>
<script language="JavaScript" src="../../js/opal2/opal2.js"></script>
<script language="JavaScript">

parent.rightFrame.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function page_view(id,grade,isbottom,parentid,cid){
    	  document.prodcategoryform.categoryid.value = id;
    	  document.prodcategoryform.grade.value = grade; 
    	  document.prodcategoryform.isbottom.value = isbottom;  
    	  document.prodcategoryform.parentcategoryid.value = parentid;
    	  document.prodcategoryform.cid.value = cid;
    	      	      	  
    	  if(id == null || id.length == 0 || id == "" || id < 0 || id == -1){
    	  	alert('<%=message.getMessageDesc("PLEASE_SELECT") %>');
    	  	return;
    	  }
    	  var link="";
    	  if(grade==null){
    	  link = "ProdSummary.jsp?<%= OvalTools.randomURL() %>&selectopt=all" + "&languagecode=" + "<%= strLanguageCode %>"+ "&orgid=" + "<%=JspHelper.filterNull( nCurOrgId )%>";
    	  }else{
    	 link = "ProdSummary.jsp?<%= OvalTools.randomURL() %>&categoryid=" + id
    	           + "&languagecode=" + "<%= strLanguageCode %>"+ "&orgid=" + "<%=JspHelper.filterNull( nCurOrgId )%>";
    	 } 
    	 parent.rightFrame.location.href = link;
}


function page_sum(flag)
{
  var catorgid = null;
  if(document.prodcategoryform.categoryorgid != null){
    catorgid = document.prodcategoryform.categoryorgid.value;
    }
  var link = "ProdSummary.jsp?<%= OvalTools.randomURL() %>&selectopt=" + flag + "&languagecode=" + "<%= strLanguageCode %>" + "&orgid=" + "<%=JspHelper.filterNull( nCurOrgId )%>" + "&categoryorgid=" + catorgid;
  parent.rightFrame.location.href = link;
}

function page_callprocedure()
{
    document.prodcategoryform.actionname.value = "callprocedure";
  	document.prodcategoryform.target = "_self";
  	isRunning = true;
  	document.prodcategoryform.submit();
}

function page_ajaxgo(){
        $('treeView1').selectedNode.clearChildren();
    	}
    	
			window.addEvent('domready', function() {	
				opal.widget.TreeView.image.path = '../../images/';	
				var treeView = new opal.widget.TreeView({
					id: 'treeView1'
				});
				
				treeView.ajaxHelper.pageName = 'prodcategorytree';
				treeView.ajaxHelper.actionName = 'gobyajax';	
				treeView.ajaxHelper.staticParams = '';	
				treeView.ajaxHelper.dynamicParams = '';	
				treeView.DataPackName = 'categorytree';								
				treeView.idName = 'categoryid';
				treeView.textName = 'categoryname';
				treeView.isBottomName = 'isbottom';
				treeView.onRequestData = function(Node, ajaxHelper){
				  if ($defined(Node.grade)){
                   ajaxHelper.dynamicParams = 'parentcategoryid=' + Node.id;					  
				  }else{
				    ajaxHelper.dynamicParams = 'grade=1';					  
				  } 
				};				
				treeView.onNodeGetData = function(Node, data){
					
				  Node.grade = data.grade;
				  Node.isbottom = data.isbottom;		  
				  Node.parentcategoryid = data.parentcategoryid;
				  Node.cid = data.categoryid;
				};
				treeView.onSelect = function(Node){
					Node.id;
				  page_view(Node.id, Node.grade, Node.isbottom, Node.parentid, Node.cid);
				};
											
				treeView.iniRoot('产品分类');
			});

function page_export(){
 window.open("<%= reportURL %>/servlet/ExcecuteReport/zylreportproduct.sox?__format=xlsx&__folder=/ovalreport");
}

</script>
</head>

<body>

<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
  <form name="prodcategoryform" method="post" action="../../Dispatcher">
       <input type="hidden" name="pagename" value="prodcategorytree">
       <input type="hidden" name="actionname">

       <input type="hidden" name="categoryid">
       <input type="hidden" name="isbottom">
       <input type="hidden" name="grade">
       <input type="hidden" name="parentcategoryid">
       <input type="hidden" name="categoryorgid" value="<%=JspHelper.filterNull( nCurOrgId )%>">
       	<input type="hidden" name="cid">

  <tr>
    <td valign="top">
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
      </table>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" height="92%">
        <tr>
          <td colspan="-1" class="deepblue-left"><img src="../../images/<%= strLanguageCode %>/quote.gif" width="16" height="11">
            <%= label.getLabelName("L_ProductCategory") + label.getLabelName("L_Colon") %></td>
        </tr>
        <tr> 
          <td cellspacing="0" width="100%"> 
          <div id=div2 style="OVERFLOW: scroll; WIDTH: 234; HEIGHT: 465">
		  <div id="treeView1"></div>						  		
		  </td>
        </tr>
        <tr> 
          <td class="td-listrom">&nbsp;</td>
        </tr>
      </table>
      <table border="0" cellspacing="1" width="100%">
        <tr> 
          <td class="td_center">
          <%--<a onclick=""><custom:button type="1" label="L_Search" imgsrc="search.gif" border="0" style="width:60"/></a>&nbsp;--%>
          <a onclick="page_sum('all')"><custom:button type="1" label="L_ViewAll" imgsrc="ViewAll.gif" border="0" style="width:60"/></a>&nbsp;
          <a onclick="page_sum('other')"><custom:button type="1" label="L_Other" imgsrc="Other.gif" border="0" style="width:60"/></a>
          <a onclick="page_export();"><custom:button type="1" label="L_ALL_Execcd" imgsrc="Other.gif" border="0" style="width:60" privilegeCode="MB-CP04"/></a>
          <!-- 
          <a onclick="page_callprocedure()"><custom:button type="1" label="L_CreateTree" imgsrc="Other.gif" border="0" style="width:60"/></a>
          </td>
           -->
        </tr>
      </table>
    </td>
  </tr>
</form>
</table>
    </body>
<script language="JavaScript">
  var ht = document.body.clientHeight - 100;
  if(ht < 0 )
    ht = 0;
  div2.style.height= ht;
</script>
<SCRIPT language=JavaScript1.2>initIt(prodcategoryform,'../../images/<%= strLanguageCode %>/');</SCRIPT>
</html>


